package cn.lyjuan.dwz_manage.core.config;

import cn.lyjuan.dwz_manage.core.java.cst.DwzCst;
import cn.lyjuan.dwz_manage.core.java.cst.DwzManageCst;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.util.Properties;

/**
 * Created by chad on 2016/8/28.
 */
@Configuration
public class CstConfig
{
    /**
     * 以dwzManage为Spring Bean ID，加载资源文件 cst/dwzmanage.properties
     *
     * @return
     */
    @Bean
    public PropertiesFactoryBean dwzManage()
    {
        PropertiesFactoryBean dwzManageCst = new PropertiesFactoryBean();

        dwzManageCst.setLocation(new ClassPathResource("cst/dwzmanage.properties"));
        return dwzManageCst;
    }

    @Bean
    public DwzManageCst dwzManageCst(Properties dwzManage)
    {
        DwzManageCst dwzManageCst = new DwzManageCst(dwzManage);
        return dwzManageCst;
    }

    /**
     * 以dwz为Spring Bean ID，加载资源文件 cst/dwz.properties
     * @return
     */
    @Bean
    public PropertiesFactoryBean dwz()
    {
        PropertiesFactoryBean dwzManageCst = new PropertiesFactoryBean();

        dwzManageCst.setLocation(new ClassPathResource("cst/dwz.properties"));
        return dwzManageCst;
    }

    @Bean
    public DwzCst dwzCst(Properties dwz)
    {
        DwzCst dwzCst = new DwzCst(dwz);

        return dwzCst;
    }
}
